import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import '../../pages/xhss/xhssHelper.dart';

import 'xhsszt_list.dart';
import 'xhsskd_list.dart';

class XHSSHome extends StatefulWidget {
  final int typeId;
  @override
  XHSSHome(this.typeId);

  @override
  createState() => new XHSSHomeState();
}

class XHSSHomeState extends State<XHSSHome> {
//  定义底部导航列表
  final List<BottomNavigationBarItem> bottomTabs = [
    new BottomNavigationBarItem(
        icon: new Icon(Icons.device_hub), label: ('设施状态记录')),
    new BottomNavigationBarItem(
        icon: new Icon(FontAwesomeIcons.file), label: ('开度调整记录')),
  ];

  Widget getBody(int i) {
    if (i == 1) return XHSSKDListPage(widget.typeId);
    if (i == 0) return XHSSZTListPage(widget.typeId);

    return new Container();
  }

  int currentIndex = 0; //当前索引
  late Widget currentPage; //当前页面

  @override
  void initState() {
    super.initState();
    currentPage = getBody(0);
  }

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return new Scaffold(
      appBar: new AppBar(
        // title: bottomTabs[currentIndex].title,
        title: Text(XHSSHelper.getName(widget.typeId)),
        /*
        actions: <Widget>[
          ElevatedButton(
            child: Icon(
              Icons.file_download,
              color: Colors.white,
            ),
            onPressed: () {
              RouteHelper.XHSSKDAdd(context,widget.typeId);
            },
          ),]*/
        // leading: Icon(Icons.menu),
      ),
      bottomNavigationBar: new BottomNavigationBar(
          type: BottomNavigationBarType.fixed,
          currentIndex: currentIndex,
          items: bottomTabs,
          fixedColor: Colors.blue,
          onTap: (index) {
            setState(() {
              currentIndex = index;
              currentPage = getBody(currentIndex);
            });
          }),
      body: currentPage,
    );
  }
}
